audit all openFd and dupping for close-on-exec
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 19:45:28 +0000 (15:45 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 20:01:41 +0000 (16:01 -0400)
commit033e4b086ffdac81072dd7d2cb0d2cc2c13e81a8
tree60e65e5e82496092d425717df624344d7c22669c
parent6ba848d2756cf7dd33c6bc5f5148d9ffca33340b
audit all openFd and dupping for close-on-exec

Made all uses of openFd and dup set the close-on-exec flag, with a few
exceptions when starting a git-annex daemon.

Made openFdWithMode be used everywhere, rather than openFd.
Adding a new parameter to it ensures I checked everything.
And will help to make sure this gets considered in the future when
opening fds.

In lockPidFile, the only thing that keeps the pid file locked, once
daemonize re-runs the command in a new session, is that the fd is
inherited.

In Utility.LogFile.redir, the new fd it dups to does not have the
close-on-exec flag set, because this is used to set up the stdout and
stderr fds, which need to be inherited by child processes.

Same in Assistant.startDaemon where the browser gets started with the
original stdout and stderr.

This does nothing about uses of openFile and similar!

Sponsored-By: mycroft
Annex/Link.hs
Command/RemoteDaemon.hs
Git/LockFile.hs
Remote/Directory.hs
Utility/Daemon.hs
Utility/DirWatcher/Kqueue.hs
Utility/LockFile/PidLock.hs
Utility/LockFile/Posix.hs
Utility/OpenFd.hs
Utility/OpenFile.hs
doc/bugs/35_failed_tests_on_beegfs/comment_7_9cfa54f7784de785cf576789ed671975._comment [new file with mode: 0644]